package com.xiaoxin.experience.service.sdk.rtsp;

import java.util.Date;

/**
 * 实况取流规则：rtsp://username:password@<ipaddress>:<port>/unicast/c<number>/s<number>/live
 * 录像取流规则：rtsp://username:password@<address>:<port>/c<number>/b<starttime>/e<endtime>/replay/
 *
 * @author xiaoxin
 */
public class YushiRtspUrlBuilder extends RtspUrlBuilder
{
    public YushiRtspUrlBuilder(String ip, String password)
    {
        super(ip, password);
    }

    @Override
    protected String buildLiveRtspUrl()
    {
        return commonPrefix() + "/unicast/c" + channelNo + "/s" + streamAdapt() +"/live";
    }

    private int streamAdapt()
    {
        return streamType.value() - 1;
    }

    private long timeStamp(Date date)
    {
        return date.getTime() / 1000;
    }

    @Override
    protected String buildRecordUrl()
    {
        return commonPrefix() + "/unicast/c" + channelNo + "/b" + timeStamp(getStartTime()) + "/e" + timeStamp(getEndTime()) + "/replay/";
    }
}
